]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspace: Don't freeze the layout when there's no layout yet
authorJonas Dreßler <verdre@v0yd.nl>
Mon, 31 Jan 2022 20:13:18 +0000 (21:13 +0100)
committerMarge Bot <marge-bot@gnome.org>
Sun, 6 Mar 2022 00:00:46 +0000 (00:00 +0000)
On some touchpads/laptops, the swipe gesture to open the overview can be
performed so fast, that it starts and ends in between two frames. Now
when this happens, and the gesture ended with too little movement to
confidently say the user intended to open the overview, we'll close the
overview again.

While closing the overview, we freeze the layout of the Workspace in
order to avoid changes to windows messing with the animation. This means
that in the case described above, we freeze the layout even before the
first frame of the opening animation happens. No frames being drawn also
means no allocations happening, and since we create this._layout in
vfunc_allocate(), this means that on the first allocation cycle of the
overview we'll see this._layoutFrozen = true, but will also not have
a this._layout nor this._windowSlots.

This creates an annoying visual glitch where for a split second all
the windows disappear (overview is visible but no WindowPreviews get
allocated).

To fix this, force creating a layout on the first allocation cycle, even
if the layout is currently frozen.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2203>

js/ui/workspace.js

index 89f89dab92cb8a8ba3ebbf1de5f25d5e0b8c8ff5..ea48006bf53f06cce1154e343d56e1b4bd7a642c 100644 (file)
@@ -424,6 +424,8 @@ var WorkspaceLayout = GObject.registerClass({
         this._windowSlots = [];
         this._layout = null;
 
+        this._needsLayout = true;
+
         this._stateAdjustment = new St.Adjustment({
             value: 0,
             lower: 0,
@@ -663,9 +665,10 @@ var WorkspaceLayout = GObject.registerClass({
         }
 
         let layoutChanged = false;
-        if (!this._layoutFrozen) {
-            if (this._layout === null) {
+        if (!this._layoutFrozen || this._needsLayout) {
+            if (this._needsLayout) {
                 this._layout = this._createBestLayout(this._workarea);
+                this._needsLayout = false;
                 layoutChanged = true;
             }
 
@@ -787,7 +790,7 @@ var WorkspaceLayout = GObject.registerClass({
         this._windows.set(window, {
             metaWindow,
             sizeChangedId: metaWindow.connect('size-changed', () => {
-                this._layout = null;
+                this._needsLayout = true;
                 this.layout_changed();
             }),
             destroyId: window.connect('destroy', () =>
@@ -807,7 +810,7 @@ var WorkspaceLayout = GObject.registerClass({
         this._syncOverlay(window);
         this._container.add_child(window);
 
-        this._layout = null;
+        this._needsLayout = true;
         this.layout_changed();
     }
 
@@ -842,7 +845,7 @@ var WorkspaceLayout = GObject.registerClass({
         if (window.get_parent() === this._container)
             this._container.remove_child(window);
 
-        this._layout = null;
+        this._needsLayout = true;
         this.layout_changed();
     }
 
@@ -861,7 +864,7 @@ var WorkspaceLayout = GObject.registerClass({
             lastWindow = window;
         }
 
-        this._layout = null;
+        this._needsLayout = true;
         this.layout_changed();
     }
 
@@ -906,7 +909,7 @@ var WorkspaceLayout = GObject.registerClass({
 
         this._spacing = s;
 
-        this._layout = null;
+        this._needsLayout = true;
         this.notify('spacing');
         this.layout_changed();
     }